/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.cong.timesheet.action;

import com.cong.timesheet.form.UserForm;
import com.cong.timesheet.model.User;
import com.cong.timesheet.service.UserService;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

/**
 *
 * @author Ram
 */
public class CreateUserAction extends Action{

    @Override
    public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
       UserForm uf=(UserForm)form;
        UserService userService=new UserService();
        User user=new User(uf.getId(),uf.getUserName(),uf.getPassword(), uf.getFirstName(),uf.getLastName(),uf.getEmail());
        userService.addUser(user);
        request.setAttribute("userlist",userService.getUsers() );
        return mapping.findForward("success");
        
        
    }
    
    
    
}
